package com.sc3.game.shared;

import java.util.EnumMap;

import com.sc3.game.shared.Technology.TechType;
import com.sc3.game.shared.Utils.CostType;

public class Construction {

	/**
	 * The level of each construction.
	 */
	public EnumMap<ConsType, Integer> mConsLevel;
	
	public static class ConsInfo{
		/**
		 * Consume resources of Population.
		 */
		public int mPopulation;
		
		/**
		 * Consume or output Energy.
		 */
		public int mEnergy;
		
		/**
		 * Consume resources of Area.
		 */
		public int mArea;

		/**
		 * The flag of advanced construction or not.
		 */
		public boolean mAdvanced = false;
		
		/**
		 * Requires technology type and level.
		 */
		public EnumMap<TechType,Integer> mTechRequires = new EnumMap<TechType,Integer>(TechType.class);
		
		/**
		 * The description of this construction.
		 */
		public String mDescription;
		
		/**
		 * Basic cost of credits.
		 */
		public int mBasicCredits;
		
		/**
		 * The additional value of economy.
		 */
		public int mEconomy;
		public CostType mCostType;
		public int mLevel;
	}

	public void a(){
		ConsType.UrbanStructures.getInfo();
	}
	
	public enum ConsType {
		UrbanStructures{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				c.mBasicCredits = 1;
				c.mCostType = CostType.TYPE1;
				c.mArea = -1;
//				c.mPopulation // specially calculate
				c.mAdvanced = false;
				c.mDescription = "Each level increases population capacity by base fertility.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		SolarPlants{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				c.mBasicCredits = 1;
				c.mCostType = CostType.TYPE1;
				
//				c.mEnergy // specially calculate
				c.mEconomy = 0;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases base energy output by base solar energy.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		GasPlants{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				c.mBasicCredits = 1;
				c.mCostType = CostType.TYPE1;
				
//				c.mEnergy ; specially calculate
				c.mEconomy = 0;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases base energy output by base gas resource.";
				
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		FusionPlants{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				c.mBasicCredits = 20;
				c.mCostType = CostType.TYPE2;

				c.mEnergy = 4;
				c.mEconomy = 0;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases base energy output by 4.";

				c.mTechRequires.put(TechType.Energy, 6);
				
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		AntimatterPlants{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 2000;
				c.mCostType = CostType.TYPE2;
				c.mEnergy = 10;
				c.mEconomy = 0;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = true;
				c.mDescription = "Each level increases base energy output by 10.";
				
				c.mTechRequires.put(TechType.Energy, 20);
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		ResearchLabs{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 2;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -1;
				c.mEconomy = 0;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases base research capacity by 6, and allows the research of more technologies.";
				
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		MetalRefineries{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 1;
				c.mCostType = CostType.TYPE1;
				
				c.mEnergy = -1;
				c.mEconomy = 1;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases production and construction capacity by base metal resource.";
				
				//No Requires
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		CrystalMines{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 2;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -1;
//				c.mEconomy //specially calculate
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases base economy by base crystals resource.";
				
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		RoboticFactories{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 5;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -1;
				c.mEconomy = 1;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mTechRequires.put(TechType.Computer, 2);
				c.mDescription = "Each level increases production and construction capacity by 2.";
				
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		Shipyards{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 5;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -1;
				c.mEconomy = 1;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases base production by 2 and allows the production of more units.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		OrbitalShipyards{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				c.mBasicCredits = 10000;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -12;
				c.mEconomy = 2;
				c.mPopulation = -1;
				c.mArea = 0;
				c.mAdvanced = false;
				
				c.mTechRequires.put(TechType.Cybernetics, 2);
				c.mDescription = "Each level increases base production by 8, allows the production of more units and doesn't require area on the base.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		Spaceports{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 5;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -1;
				c.mEconomy = 2;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases base economy by 2 and allows trade routes.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		CommandCenters{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 20;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -1;
				c.mEconomy = 0;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = false;
				c.mDescription = "Each level increases the number of occupied bases you can have by 1, and add 5% fleet attack power at base location.";

				c.mTechRequires.put(TechType.Computer, 6);
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		NaniteFactories{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				
				c.mBasicCredits = 80;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -2;
				c.mEconomy = 2;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = true;
				c.mDescription = "Each level increases production and construction capacity by 4.";

				c.mTechRequires.put(TechType.Computer, 10);
				c.mTechRequires.put(TechType.Laser, 8);
				ConsInfoMap.put(this, c);
				return c;
			}
		},
		AndroidFactories{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				ConsInfoMap.put(this, c);
				
				c.mBasicCredits = 1000;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -4;
				c.mEconomy = 2;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = true;
				c.mDescription = "Each level increases production and construction capacity by 6.";

				c.mTechRequires.put(TechType.ArtificialIntelligence, 4);
				
				return c;
			}
		},
		EconomicCenters{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				c.mBasicCredits = 80;
				c.mCostType = CostType.TYPE2;
				
				c.mEnergy = -2;
				c.mEconomy = 3;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mAdvanced = true;
				
				c.mTechRequires.put(TechType.Computer, 10);
				c.mDescription = "Each level increases base economy by 3.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		Terraform{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				c.mBasicCredits = 80;
				c.mCostType = CostType.TYPE2;
				c.mArea = 5;
				c.mAdvanced = true;
				c.mTechRequires.put(TechType.Computer, 10);
				c.mTechRequires.put(TechType.Energy, 10);
				c.mDescription = "Each level increases base construction area by 5, doesn't require population.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		MultiLevelPlatforms{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
		
				c.mBasicCredits = 10000;
				c.mCostType = CostType.TYPE2;
				c.mArea = 10;
				c.mAdvanced = true;
				c.mTechRequires.put(TechType.Armour, 22);
				c.mDescription = "Each level increases base construction area by 10, doesn't require population.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		OrbitalBase{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				

				c.mBasicCredits = 2000;
				c.mCostType = CostType.TYPE2;
				c.mPopulation = 10;
				c.mAdvanced = true;
				c.mTechRequires.put(TechType.Computer, 20);
				c.mDescription = "Each level increase population capacity by 10 and doesn't require area on the base.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		JumpGate{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
			
				c.mBasicCredits = 5000;
				c.mCostType = CostType.TYPE2;
				c.mEnergy = -8;
				c.mPopulation = -1;
				c.mTechRequires.put(TechType.Energy, 20);
				c.mTechRequires.put(TechType.WarpDrive, 12);
				c.mDescription = "Each level increases fleet speed by 100%, allows stellar units to move between galaxies (can be used by guild members).";

				ConsInfoMap.put(this, c);
				
				return c;
			}
		},
		BiosphereModification{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				c.mBasicCredits = 20000;
				c.mCostType = CostType.TYPE2;
				c.mEnergy = -24;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mTechRequires.put(TechType.Computer, 24);
				c.mTechRequires.put(TechType.Energy, 24);
				c.mDescription = "Each level increases astro fertility by 1.";

				ConsInfoMap.put(this, c);
				return c;
			}
		},
		Capital{
			public ConsInfo getInfo(){
				if(ConsInfoMap.containsKey(this)){
					return ConsInfoMap.get(this);
				}
				ConsInfo c = new ConsInfo();
				
				c.mBasicCredits = 15000;
				c.mCostType = CostType.TYPE2;
				c.mEnergy = -12;
				c.mEconomy = 10;
				c.mPopulation = -1;
				c.mArea = -1;
				c.mTechRequires.put(TechType.TachyonCommunications, 1);
				c.mDescription = "Each level increases base econ. by 10 and all other bases by 1. Can only exist at one base. -15% empire income while occupied.";

				ConsInfoMap.put(this, c);
				return c;
			}
		};
		abstract ConsInfo getInfo();   
		public EnumMap<ConsType, ConsInfo> ConsInfoMap = new EnumMap<ConsType, ConsInfo>(ConsType.class);
	}
	
	
	
}
